/**
 * Created by Administrator on 2017\9\21 0021.
 */

//确认
function savesuccess(id, hh) {
    console.log('operation');
	var work_order_id = $("input[name='workOrderStatus" + id + "']").val();
	var work_order_status = $("#_orderStatus" + work_order_id + " option:selected").val();
	var remarks = $("#remarks" + work_order_id).val();
	
	var srcs = "/operation/workorder/index";
	
	// if(hh == 1) { // 续费
	// 	var srcs = "/operation/workorder/renew";
	// }
	// if(hh == 2) { // 换芯
	// 	var srcs = "/operation/workorder/core";
	// }
	// if(hh == 5) { // 详情页面操作
	// 	var srcs = "/operation/workorder/detail?id=" + id;
	// }

	$.getJSON("/operation/workorder/status", {
		remarks: remarks,
		work_order_status: work_order_status,
		work_order_id: work_order_id
	}, function(data) {
		
		if(data.status == 0) {
			parent.layer.msg(data.message, {
				time: 1000,
				icon: 2
			});
		} else {
			parent.layer.msg(data.message, {
				time: 1000,
				icon: 1
			});
			$("#mainFrame").attr("src", srcs)
		}
	});

	$(".layui-layer-shade").remove();
	$(".layui-layer").remove();

}
//保存备注
    function saveRemarks(id){
        console.log('operation');
        var add_remarks = $("#add_remarks").val();
        $.getJSON("/operation/workorder/addRemarks", {
            remarks: add_remarks,
            work_order_id: id
        }, function(data) {
            if(data.status == 0) {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 2
                });
            } else {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 1
                });
               setTimeout(function(){
                    $(".layui-layer-shade").remove();
                    $(".layui-layer").remove();
                    $("#mainFrame").attr("src", "/operation/workorder/index")
                },2000)};
              
        });
    }
    //保存备注
    function saveVisit(id){
        var remarks = $("#visit_remarks").val();
        var visit_status = $("#_visitStatus"+id+" option:selected").val();
        $.getJSON("/operation/workorder/returnVisit", {
            remarks: remarks,
            visit_status:visit_status,
            work_order_id: id
        }, function(data) {
            if(data.status == 0) {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 2
                });
            } else {
                parent.layer.msg(data.message, {
                    time: 1000,
                    icon: 1
                });
               setTimeout(function(){
                    $(".layui-layer-shade").remove();
                    $(".layui-layer").remove();
                   $("#mainFrame").attr("src", "/operation/workorder/index")
                },2000)};
              
        });
    }


//取消
function layuihide() {
	$(".layui-layer").remove();
	$(".layui-layer-shade").remove();
}

// 实名审核
function realnameOperation (id,user_id) {
    var status = $("#_orderStatus"+id+" option:selected").val();
    var remarks = $("#remarks"+id).val();
    var srcs = "/operation/realname/index";
    $.getJSON("/operation/realname/status",{remarks:remarks,status:status,auth_id:id,user_id:user_id},function(data){

        if (data.status == 0) {
            layer.msg(data.message, {time: 1000,icon: 2});
        }else{
            layer.msg(data.message, {time: 1000,icon: 1});
            $("#mainFrame").attr("src",srcs)
        }
    });

    $(".layui-layer-shade").remove();
    $(".layui-layer").remove();
}
function jumpcustome() {
	$("#mainFrame").attr('src', '/operation/Customerinfo/add' + '#equipment');
	cancelmodel();
}

// 指派工程人员弹窗，新增工程人员按钮
function engineeradd() {
    $("#mainFrame").attr('src', '/operation/Engineer/add' + '#equipment');
    cancelmodel();
}